<?php
class ProvidersController extends AppController{
var $name = "Providers";	
 var $helpers = array('Html','Ajax','Javascript','Form');
 var $paginate = array(
        'limit' =>10,
        'order' => array('Provider.name' => 'asc')
    );
function index($id = null){
	$this->layout = "home";	
	$this->Provider->id = $id;
	$this->set('iProvider',$this->Provider->read());
	//$this->set('provider', $this->Provider->find('all'));
	
	$data = $this->paginate('Provider');
        $this->set('provider', $data);
}
function save(){
		$id= $_REQUEST['id'];
		$name = $_REQUEST['name'];
		$address = $_REQUEST['address'];
		$phone = $_REQUEST['phone'];
		$description = $_REQUEST['description'];
		if($id !=null && $id !=""){
			$this->Provider->set('id',$id);
			$this->Provider->set('name',$name);
			$this->Provider->set('address',$address);
			$this->Provider->set('phone',$phone);
			$this->Provider->set('description',$description);
			$this->Provider->save();
		}
		else
		{
			$this->Provider->create();
			$this->Provider->set('name',$name);
			$this->Provider->set('address',$address);
			$this->Provider->set('phone',$phone);
			$this->Provider->set('description',$description);
			$this->Provider->saveAll();
		}
		$this->redirect(array("action" => "index", $this->Provider->id));
	}
function delete() {
		$id= $_REQUEST['id'];
		if($id !=null && $id !=""){
		$this->Provider->delete($id);
		$this->redirect(array('action'=>'index'));
		}
	}
	
}
?>